class Solution(object):
    def findLongestChain(self, pairs):
        """
        :type pairs: List[List[int]]
        :rtype: int
        """
        pairs.sort()
        now_count = 1
        n = len(pairs)
        last = pairs[0][1]
        for i in range(1, n):
            if pairs[i][0] > last:
                now_count += 1
                last = pairs[i][1]
            else:
                last = min(last, pairs[i][1])
        return now_count

data = Solution()
pairs = [[1, 2], [2, 3], [3, 4]]
print(data.findLongestChain(pairs))
